#===============================================================================
# Koro Business Environment
# Copyright (C) 2008  Antonio Corroppoli
#
#This file is part of Koro BE.
# 
# Koro BE is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
# 
# Koro BE is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with Koro BE; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
#===============================================================================

'''
Created on 11/ago/2011

@author: antstud
'''
import wx
from koro.ui.wxgui.pages import AbstractPage
from koro.modules.home.ui import panel

#===============================================================================
# HomePage
#===============================================================================
class HomePage(wx.ScrolledWindow,AbstractPage):
    TITLE='Pagina Iniziale'
    def __init__(self,parent,context,objects,*args,**kwargs):
        super(HomePage,self).__init__(parent,*args,**kwargs)
        #self.scrolling_window = wx.ScrolledWindow( self )
        self.SetScrollRate(1,1)
        self.EnableScrolling(True,True)
        mainsizer = wx.BoxSizer( wx.VERTICAL )
        vsizer = wx.BoxSizer(wx.VERTICAL  )
        
        self.titolo=panel.TitoloPanel(self)
        vsizer.Add(self.titolo,0,wx.EXPAND|wx.CENTER|wx.ALL, 5)
        
        #self.attivita=AttivitaPanel(self,size=(200,200))
        self.attivita=wx.Panel(self,size=(200,200))        
        vsizer.Add(self.attivita, 0,wx.EXPAND| wx.CENTER|wx.ALL, 5)
        vsizer.AddSpacer(10)
        
        self.memo=panel.ImpegniPanel(self,size=(200,100))
        vsizer.Add(self.memo, 0, wx.EXPAND|wx.CENTER|wx.ALL, 5)
        vsizer.AddSpacer(10)
        
        self.lavagna=panel.LavagnaPanel(self,size=(200,400))
        vsizer.Add(self.lavagna, 0, wx.EXPAND|wx.CENTER|wx.ALL, 5)
        mainsizer.Add(vsizer,1,wx.EXPAND)
        
        self.SetSizer(mainsizer)
        self.SetAutoLayout(True)
        #self.Layout()
    
    def update(self):
        self.titolo.update()
        #self.attivita.update()
        self.memo.update()
    
    def on_page_focus(self):
        self.update()
    
    def before_close(self):
        lavagna=self.lavagna.get_contenuto()
        observer=wx.GetApp().get_observer()
        observer.set_context('LAVAGNA')
        observer.save_object(lavagna)